/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘国水
 * Date: 2025-07-24
 * Time: 17:12
 */


public class Test {


    private static long result = 0;

    public static void main(String[] args) throws InterruptedException {

        Thread t = new Thread(() -> {
            for (int i = 1; i <= 1000; i++) {
                result += i;
            }
            System.out.println("线程运行完毕");
        });
        t.start();
        Thread.sleep(1);
        System.out.println(result);
    }
    //此处定义⼀个int 类型的变量

//    private static int count = 0;
//
//    public static void main(String[] args) throws InterruptedException {
//        Thread t1 = new Thread(() -> {
//
//            //count 变量进⾏⾃增 5w 次
//
//            for (int i = 0; i < 50000; i++) {
//                count++;
//            }
//        });
//        Thread t2 = new Thread(() -> {
//            //对 count 变量进⾏⾃增 5w 次
//
//            for (int i = 0; i < 50000; i++) {
//                count++;
//            }
//        });
//        t1.start();
//        t2.start();
//        t1.join();
//        t2.join();
//        //如果没有这俩 join, 肯定不⾏的.线程还没⾃增完, 就开始打印了.很可能打印出来的 count就是个0
//        //预期结果应该是 10w
//        System.out.println("count: " + count);

//    public static void main(String[] args) {
//        for (Thread.State state : Thread.State.values()) {
//            System.out.println(state);
//        }
//    }

//    public static void main(String[] args) throws InterruptedException {
//        System.out.println(System.currentTimeMillis());
//        Thread.sleep(3 * 1000);
//        System.out.println(System.currentTimeMillis());
//    }

//    public static void main(String[] args) {
//        Thread t =  Thread.currentThread();
//        System.out.println(t.getName());
//    }

//    public static void main(String[] args) {
//        Thread thread = Thread.currentThread();
//        System.out.println(thread.getName());
//    }


//    public static void main(String[] args) {
//        int a = 10;
//        int b = 20;
//        System.out.println(a+b);
//    }
    }
